home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
linuxcon.000
/
linuxcon
/
linuxconf-1.6
/
main
/
linuxconf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-01
|
5KB
|
175 lines
#include <unistd.h>
#include "../askrunlevel/askrunlevel.h"
#include "../misc/misc.h"
#include "../xconf/xconf.h"
#include "../netconf/netconf.h"
#include "../userconf/userconf.h"
#include "../fstab/fstab.h"
#include "../main/main.h"
#include "../paths.h"
#include "main.m"
static HELP_FILE help_intro (HELP_MAIN,"intro");
static HELP_FILE help_control (HELP_MAIN,"control");
static HELP_FILE help_shutdown (HELP_MAIN,"shutdown");
/*
Interactive control of a shutdown or reboot
*/
static void linuxconf_boot()
{
DIALOG dia;
char oper=0;
dia.newf_radio ("",oper,0,MSG_U(F_REBOOT,"Reboot"));
dia.newf_radio ("",oper,1,MSG_U(F_HALT,"Shutdown & halt"));
int grace = 1;
dia.newf_num (MSG_U(F_DELAI,"Delay before shutdown(minutes)"),grace);
SSTRING message;
dia.newf_str (MSG_U(F_MESSAGE,"Message"),message);
if (dia.edit (MSG_U(T_SHUTDOWN,"Shutdown control panel")
,MSG_U(I_SHUTDOWN,"You can force a reboot or a final shutdown\n"
"of this computer")
,help_shutdown
,0)==MENU_ACCEPT){
setuid (0);
chdir ("/");
char timestr[10];
sprintf (timestr,"+%d",grace);
execl ("/sbin/shutdown","/sbin/shutdown"
,oper == 0 ? "-r" : "-h"
,timestr,message.get(),NULL);
}
}
/*
control panel to activate different things, not to configure.
Return != 0 if the last task done was an "update" of the system state
*/
static int linuxconf_control()
{
int choice = 0;
int was_checked = 0;
while (1){
static const char *run_level = MSG_U(M_RUNLEVEL,"init Run Level");
static const char *reboot = MSG_U(M_REBOOT,"Shutdown/Reboot");
static const char *update = MSG_U(M_UPDATE,"Activate configuration");
static const char *menuopt[]={
" ", update,
" ", reboot,
//" ", run_level,
NULL
};
MENU_STATUS code = xconf_menu (MSG_U(T_CONTROL,"Control panel")
,MSG_U(I_CONTROL
,"This menu let you do things, not configure.")
,help_control
,menuopt,choice);
if (code != MENU_OK){
break;
}else if (perm_rootaccess (MSG_U(Q_SYSTASK,"to perform system task"))){
was_checked = 0;
const char *key = menuopt[choice*2+1];
if (key == update){
int status = netconf_checkupdate();
was_checked = status != -1;
if (status == 0) xconf_notice (MSG_U(N_NOJOB,"Nothing to do!"));
}else if (!simul_isdemo()){
if (key == reboot){
linuxconf_boot();
}else if (key == run_level){
}
}else{
xconf_error (MSG_U(E_DEMO,"Not in demo mode"));
}
}
}
return was_checked;
}
/*
Main dispatcher to all other configs
*/
void linuxconf_main(int dontcheck)
{
int choice = 0;
int was_checked = 0;
while (1){
static const char *config_basic = MSG_U(MNU_BASIC,"basic host information");
static const char *config_askrun = MSG_U(MNU_BOOT,"boot mode");
static const char *view_logs = MSG_U(MNU_LOGS,"logs");
static const char *config_fstab = MSG_U(MNU_FILESYS,"File systems");
static const char *config_graphic= MSG_U(MNU_GRAPH,"Graphic mode (X)");
static const char *config_net = MSG_U(MNU_NET,"Networking");
static const char *config_user = MSG_U(MNU_USERS,"Users accounts");
static const char *config_datetime = MSG_U(MNU_DATE,"date & time");
static const char *config_file = MSG_U(MNU_CONFIGS,"all configuration files");
static const char *commands = MSG_U(MNU_COMMANDS,"all commands and daemons");
static const char *control = MSG_U(MNU_CONTROL,"Control panel");
static const char *config_module = MSG_U(MNU_MODULE,"Linuxconf's modules");
static const char *menuopt[]={
MSG_U(MNU_CONFIG,"Configure"),config_basic,
" ", config_net,
" ", config_user,
" ", config_fstab,
" ", config_graphic,
" ", config_askrun,
" ", config_module,
MSG_U(MNU_SET,"Set"), config_datetime,
"-", "",
" ", control,
MSG_U(MNU_VIEW,"View"), view_logs,
MSG_U(MNU_LIST,"List"), config_file,
" ", commands,
NULL
};
char title[80];
extern char *revision;
sprintf (title,"%s %s"
,MSG_U(TITLE,"LINUX Configuration manager"),revision);
MENU_STATUS code = xconf_menu (title
,MSG_U(MNU_INTRO,"This is the main entry to Linux configuration.\n"
"\n"
"Use the TAB key to nagigate between the field\n"
"section and the button bar at the bottom\n"
"Check out the help of this screen. It is an\n"
"introduction to Linuxconf")
,help_intro
,menuopt,choice);
if (code != MENU_OK){
break;
}else{
was_checked = 0;
const char *key = menuopt[choice*2+1];
if (key == config_basic){
netconf_edithost();
}else if (key == config_fstab){
fstab_edit ();
}else if (key == config_graphic){
xconf_edit ();
}else if (key == config_net){
netconf_edit ();
}else if (key == config_askrun){
askrunlevel_config();
}else if (key == config_module){
module_config();
}else if (key == view_logs){
boot_showlog();
}else if (key == config_user){
userconf_edit();
}else if (key == config_file){
configf_show();
}else if (key == commands){
daemon_config();
}else if (key == config_datetime){
datetime_edit();
}else if (key == control){
was_checked = linuxconf_control();
}
}
}
if (!dontcheck && !was_checked) netconf_checkupdate();
}